﻿<UserControl xmlns:controlsToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
             xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
			 xmlns:dataFormToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit" 
	x:Class="IndexMarkSilverlightClient.MainPage"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" 
	xmlns:uriMapper="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
	xmlns:viewmodel="clr-namespace:IndexMarkSilverlightClient"        
	xmlns:classes="clr-namespace:IndexMarkSilverlightClient.Classes"
    xmlns:shared="clr-namespace:SharedCode;assembly=SharedCode"
    xmlns:converters="clr-namespace:IndexMarkSilverlightClient.Classes.Converters"
	mc:Ignorable="d" d:DesignWidth="1024" d:DesignHeight="768"
	Loaded="UserControl_Loaded">
	
    <UserControl.Background>
		<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
			<GradientStop Color="Black" Offset="0" />
			<GradientStop Color="#FFA06F6F" Offset="1" />
		</LinearGradientBrush>
	</UserControl.Background>
	
    <UserControl.Resources>
		<viewmodel:MainViewModel x:Key="MainViewModel" d:IsDataSource="True" />
		<classes:VisToBoolConverter x:Key="VisToBoolConverter"/>
        <shared:DateTimeToYearConverter x:Key="DateTimeToYearConverter"/>
        <shared:DateTimeToDateConverter x:Key="DateTimeToDateConverter"/>
        <converters:TermToHasEditConverter x:Key="TermToHasEditConverter"/>
        <converters:TermToColorConverter x:Key="TermToColorConverter"/>
	</UserControl.Resources>

	<Grid x:Name="LayoutRoot" Style="{StaticResource LayoutRootGridStyle}">

		<Border x:Name="ContentBorder" Style="{StaticResource ContentBorderStyle}" Margin="25,80,25,18">

			<navigation:Frame x:Name="ContentFrame" Style="{StaticResource ContentFrameStyle}"
							  Source="/InputMain" Navigated="ContentFrame_Navigated" NavigationFailed="ContentFrame_NavigationFailed" Margin="0">
				<navigation:Frame.UriMapper>
					<uriMapper:UriMapper>
						<uriMapper:UriMapping Uri="/InputMain" MappedUri="/Views/InputMain.xaml"/>
						<uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml"/>
					</uriMapper:UriMapper>
				</navigation:Frame.UriMapper>
			</navigation:Frame>
		</Border>

		<Grid x:Name="NavigationGrid" Style="{StaticResource NavigationGridStyle}" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="False" d:LayoutRounding="Auto" Margin="0">
			<Grid.RenderTransform>
				<TransformGroup>
					<ScaleTransform/>
					<SkewTransform/>
					<RotateTransform Angle="-0.165"/>
					<TranslateTransform/>
				</TransformGroup>
			</Grid.RenderTransform>

			<Border x:Name="BrandingBorder" Style="{StaticResource BrandingBorderStyle}" Margin="0,0,24.53,0" Width="auto">
                <StackPanel x:Name="BrandingStackPanel" Style="{StaticResource BrandingStackPanelStyle}" Orientation="Horizontal">
                    <TextBlock x:Name="ApplicationNameTextBlock" Style="{StaticResource ApplicationNameStyle}" Width="auto" Text="Система материального стимулирования ППС" HorizontalAlignment="Left" Margin="10, 0, 0, 0" />
                    <StackPanel Orientation="Horizontal" Margin="10, 0, 0, 15">
                        <TextBlock Height="13" Name="textBlock1" Text="Сборка " FontSize="9" Foreground="White"/>
                        <TextBlock FontSize="9" Height="13" Name="BuildNumberTextBlock" Text="{Binding Version, Source={StaticResource MainViewModel}}" Foreground="White"/>
                    </StackPanel>
                </StackPanel>
            </Border>

            <Border x:Name="_bError" Visibility="Collapsed" Margin="0,23,24.53,0" Height="37" 
                    Style="{StaticResource BrandingBorderStyle}" Width="594.583" Background="Red">
                <controlsToolkit:DockPanel >
                    <StackPanel controlsToolkit:DockPanel.Dock="Right" Margin="2">
                        <HyperlinkButton x:Name="_Help" NavigateUri="/About" 
                                         ToolTipService.ToolTip="Перейти на вкладку с координатами техподдержки и описанием действий при ошибке." 
                                       TargetName="ContentFrame" Content="Помощь" />
                        <HyperlinkButton x:Name="_Close" ToolTipService.ToolTip="Скрыть это сообщение"
                                       Content="Скрыть" HorizontalAlignment="Center" Click="Button_Click_1"/>
                    </StackPanel>
                     <TextBlock Name="_tError" HorizontalAlignment="Center" 
                               FontSize="12" TextWrapping="Wrap" FontWeight="Bold" />
                </controlsToolkit:DockPanel>
            </Border>

            <Border x:Name="LinksBorder" Style="{StaticResource LinksBorderStyle}" Margin="65,17,0,-16">
				<StackPanel x:Name="LinksStackPanel" Style="{StaticResource LinksStackPanelStyle}">

					<HyperlinkButton x:Name="Link1" Style="{StaticResource LinkStyle}" NavigateUri="/InputMain" TargetName="ContentFrame" ToolTipService.ToolTip="Страница ввода и просмотра данных по ИС" Content="Показатели ППС"/>

					<Rectangle x:Name="Divider1" Style="{StaticResource DividerStyle}" Visibility="Visible"/>
					<HyperlinkButton x:Name="Link2" Style="{StaticResource LinkStyle}" NavigateUri="/ReportsMain" ToolTipService.ToolTip="Страница просмотра статстики по ИС" TargetName="ContentFrame" Content="Статистика" Visibility="Visible"/>
					
					<Rectangle x:Name="Divider3" Style="{StaticResource DividerStyle}" Visibility="{Binding User.IsSupervisor, Source={StaticResource MainViewModel}, Converter={StaticResource VisToBoolConverter}}"/>
					<HyperlinkButton x:Name="Link4" NavigateUri="/Admin" ToolTipService.ToolTip="Страница администрирования ИС" Style="{StaticResource LinkStyle}" Visibility="{Binding User.IsSupervisor, Source={StaticResource MainViewModel}, Converter={StaticResource VisToBoolConverter}}" TargetName="ContentFrame" Content="Администрирование" Click="Link4_Click" />

					<Rectangle x:Name="Divider4" Style="{StaticResource DividerStyle}"/>
					<HyperlinkButton x:Name="Link5" ToolTipService.ToolTip="Документация по системе материального стимулирования ППС" Style="{StaticResource LinkStyle}" NavigateUri="/Documents" TargetName="ContentFrame" Content="Документация"/>

					<Rectangle x:Name="Divider5" Style="{StaticResource DividerStyle}"/>
					<HyperlinkButton x:Name="Link6" Style="{StaticResource LinkStyle}" ToolTipService.ToolTip="Руководство пользователя" NavigateUri="/HelpMain" TargetName="ContentFrame" Content="Справка"/>

					<Rectangle x:Name="Divider2" Style="{StaticResource DividerStyle}"/>
					<HyperlinkButton x:Name="Link3" Style="{StaticResource LinkStyle}" ToolTipService.ToolTip="Техническая поддержка" NavigateUri="/About" TargetName="ContentFrame" Content="Техническая поддержка"/>
				</StackPanel>
			</Border>
			
			<StackPanel Orientation="Horizontal" Background="Transparent" HorizontalAlignment="Right" Margin="0,0,25.374,-13" VerticalAlignment="Bottom">
				<TextBlock VerticalAlignment="Center" Text="Пользователь: " TextWrapping="Wrap" Foreground="Black"/>
				<TextBlock x:Name="User_Name" Text="{Binding Path=User.Name, Source={StaticResource MainViewModel}}" TextWrapping="Wrap" VerticalAlignment="Center" Margin="5, 0, 0, 0"/>
				<Image Source="Views/Resources/Information.png" Width="22" Height="22" Margin="5, 0, 0, 0">
					
					<ToolTipService.ToolTip>
						<ToolTip Background="Transparent" BorderBrush="Transparent" BorderThickness="0" Padding="0">
							<Border CornerRadius="5" BorderBrush="#FF2754DD" BorderThickness="2" Background="#FFBADADA">
								<ListBox Background="Transparent" ItemsSource="{Binding Path=User.Roles, Source={StaticResource MainViewModel}}" BorderBrush="Transparent" BorderThickness="0">
									<ListBox.ItemTemplate>
										<DataTemplate>
											<TextBlock Text="{Binding}"/>
										</DataTemplate>
									</ListBox.ItemTemplate>
								</ListBox>
							</Border>
						</ToolTip>
					</ToolTipService.ToolTip>
					
				</Image>
			</StackPanel>
				
			<Button Click="Button_Click" Width="24" Height="24" Margin="24,14,0,24" HorizontalAlignment="Left" Opacity="0.8">
				<Button.Content>
					<Image Source="Views/Resources/FullScreenHS.png"/>
				</Button.Content>
				<ToolTipService.ToolTip>
					<ToolTip>
						<TextBlock Text="Полный экран"/>
					</ToolTip>
				</ToolTipService.ToolTip>
			</Button>
            <classes:CMessage HorizontalAlignment="Left" Margin="170,8,0,0" x:Name="cMessage1" VerticalAlignment="Top" MaxWidth="350" />
            <ComboBox Margin="66,3,0,0" HorizontalAlignment="Left" Width="100" Height="24" x:Name="OrganizationComboBox" ItemsSource="{Binding Path=Organizations, Source={StaticResource MainViewModel}}" SelectionChanged="OrganizationComboBox_SelectionChanged" ToolTipService.ToolTip="Раздел индексной системы" VerticalAlignment="Top">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Path=Name}"/>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
            <Border x:Name="HasEditBorder" HorizontalAlignment="Left" BorderThickness="2" Margin="168.017,9,0,23" Width="160" Height="Auto" Visibility="Visible" CornerRadius="3">
                <Border.BorderBrush>
                    <Binding ElementName="TermComboBox" Path="SelectedItem" Converter="{StaticResource TermToColorConverter}"/>
                </Border.BorderBrush>
				<StackPanel Orientation="Vertical" Margin="5, 0, 0, 0">
                    <TextBlock>
                        <TextBlock.Text>
                            <Binding ElementName="TermComboBox" Path="SelectedItem" Converter="{StaticResource TermToHasEditConverter}"/>      
                        </TextBlock.Text>
                    </TextBlock>
					<StackPanel Orientation="Horizontal">
                        <TextBlock>
                            <TextBlock.Text>
                                <Binding ElementName="TermComboBox" Path="SelectedItem.StartFill" Converter="{StaticResource DateTimeToDateConverter}"/>      
                            </TextBlock.Text>
                        </TextBlock>
						<TextBlock Text=" - "/>
                        <TextBlock>
                            <TextBlock.Text>
                                <Binding ElementName="TermComboBox" Path="SelectedItem.StopFill" Converter="{StaticResource DateTimeToDateConverter}"/>      
                            </TextBlock.Text>
                        </TextBlock>
                    </StackPanel>
				</StackPanel>
			</Border>

            <Button Visibility="Collapsed" ToolTipService.ToolTip="Подписка на уведомления" x:Name="SubscribeButton" Click="SubscribeButton_Click" HorizontalAlignment="Left" Height="19" Width="30" Margin="332,14,0,24">
                <StackPanel Orientation="Horizontal">        
                    <Image Width="16" Height="13" Source="Views/Resources/Subscribe/mail_off.png" />     
                    <!--<TextBlock VerticalAlignment="Center" Margin="2,0,0,0" Text="Откл." />-->               
                </StackPanel>       
            </Button>

        </Grid>
        <ComboBox Margin="66,28,0,0" HorizontalAlignment="Left" Width="100" Height="24" x:Name="TermComboBox" ItemsSource="{Binding Path=TermsOrg, Source={StaticResource MainViewModel}}" SelectionChanged="TermComboBox_SelectionChanged" ToolTipService.ToolTip="Период" VerticalAlignment="Top">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Path=Start, Converter={StaticResource DateTimeToYearConverter}}" />
                        <TextBlock Text="/" />
                        <TextBlock Text="{Binding Path=Stop, Converter={StaticResource DateTimeToYearConverter}}" />
                    </StackPanel>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>
    </Grid>

</UserControl>